#!/usr/bin/env python

import platform, datetime, time
#from time import time

server = platform.node()
server = 'checkmk7'
site = 'labf'

# Nagios command file
com_file = '/opt/omd/sites/' + site + '/tmp/run/nagios.cmd'
print (com_file)

# Time details in Unix format
time_fmt = '%m-%d-Y %T'
now = datetime.datetime.strftime(datetime.datetime.now(), '%s')
start_time= time.strftime('%s')
end_time = int(time()+2700)

# Open the command file in write mode
cfile = open(com_file, 'a')

# Nagios command for scheduling downtime

try:
	print ('[' + now + '] SCHEDULE_HOST_DOWNTIME;' + server + ';' + str(start_time) + ';' + str(end_time) + ';1;0;0;omdadmin;Scheduled Downtime')
	fd.write('[' + now + '] SCHEDULE_HOST_DOWNTIME;' + server + ';' + str(start_time) + ';' + str(end_time) + ';1;0;0;omdadmin;Scheduled Downtime')
except:
	raise

# Close the file handle
cfile.close()
